<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title>借阅面板</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

	<script src="../../scripts/boot.js" type="text/javascript"></script>


	<style type="text/css">
		html,
		body {
			padding: 0;
			margin: 0;
			border: 0;
			height: 100%;
			overflow: hidden;
		}
	</style>
</head>

<body>

	<form id="form1" method="post">
		<div style="padding-left: 11px; padding-bottom: 5px;">
			<table style="table-layout: fixed;">
				<tr>

					<td>借阅人：</td>
					<td><input name="borrower" class="mini-textbox" required="true" emptyText="请输入姓名" /></td>

					<td>联系电话 ：</td>
					<td><input name="phone" class="mini-textbox" maxlength="11" required="true" emptyText="请输入电话号码" />
					</td>
				</tr>

				<tr>
					<td>书籍：</td>
					<td><input name="bookid" class="mini-combobox" id="bookid"
							url="../../borrowinfoaddaction?method=addborrowinfo" textField="bookname"
							valueField="bookid" emptyText="请选择书籍" onValuechanged="changed" /></td>
					<td>借阅号 ：</td>
					<td><input id="borrowid" name="borrowid" class="mini-textbox" allowinput="false" /></td>
				</tr>

				<tr>
					<td>借阅时间 ：</td>
					<td><input id="date1" class="mini-datepicker" name="borrowtime" style="width: 200px;"
							nullValue="借阅时间" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true"
							showOkButton="true" showClearButton="false" allowinput="false" /></td>
					<td>还书时间 ：</td>
					<td><input id="date2" class="mini-datepicker" style="width: 200px;" name="returntime" 
							format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" showOkButton="true"
							showClearButton="false" allowinput="false" /></td>
				</tr>


				<tr><input name="bookname" id="bookname" class="mini-textbox" style="display: none;" /></tr>
			</table>
		</div>

		<div style="text-align: center; padding: 10px;">
			<a class="mini-button" onclick="onOk" style="width: 60px; margin-right: 20px;">确定</a> <a class="mini-button"
				onclick="onCancel" style="width: 60px;">取消</a>
		</div>
	</form>
	<script type="text/javascript">
		mini.parse();
		mini.get('date1').setValue(new Date);

		var form = new mini.Form("form1");

		// 设置borrowid
		$.ajax({
			url: "../../borrowinfoaddaction",
			cache: false,
			data: {
				method: "getBorrowID"
			},
			success: function (text) {
				mini.get("borrowid").setValue(text);
			}
		})

		function SaveData() {
			var o = form.getData();
			form.validate();
			if (form.isValid() == false)
				return;
			var json = mini.encode(o);

			//将表单数据发送给后端
			$.ajax({
				url: "../../borrowinfoaddaction?method=querybookinfo",
				type: 'post',
				data: {
					data: json
				},
				cache: false,
				success: function (text) {
					var res = mini.decode(text);
					mini.confirm(res.msg, "借阅图书", function (action) {
						CloseWindow("save");
					});
				},
				error: function (jqXHR, textStatus, errorThrown) {
					alert(jqXHR.responseText);
					CloseWindow();
				}
			});
		}


		function GetData() {
			var o = form.getData();
			return o;
		}


		function CloseWindow(action) {
			if (action == "close" && form.isChanged()) {
				if (confirm("数据被修改了，是否先保存？")) {
					return false;
				}
			}
			if (window.CloseOwnerWindow)
				return window.CloseOwnerWindow(action);
			else
				window.close();
		}

		function onOk(e) {
			SaveData();
		}
		function onCancel(e) {
			CloseWindow("cancel");
		}


		function onDeptChanged(e) {
			var positionCombo = mini.getbyName("position");
			var dept_id = deptCombo.getValue();
			positionCombo.setValue("");
		}
		function changed() {
			var input = mini.get("bookid");
			mini.get("bookname").setValue(input.text);
		}

		function SetData(data) {
			mini.get("bookid").setValue(data.bookId);
		}
	</script>
</body>

</html>